package com.example.cloudapirabbitmq.simple;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

// 生产者
@Controller
public class SimpleProducer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/send")
    @ResponseBody
    public String send(Person person) {
        rabbitTemplate.convertAndSend("simple.queue", person.toString());
        return "sended...";
    }

    @RequestMapping("/")
    @ResponseBody
    public String test() {
        return "OK...";
    }
}